/******************************************************************
 * @version      : 1.0
 * @Author       : zhl
 * @Date         : 2023-05-17 16:38:01
 * @LastEditors  : zhl
 * @E-Mail       : zhll168@163.com
 * @Description  : 业务描述
 ******************************************************************/

#include "JsonManager.h"
#include "upgrade_data.h"
#include "JsonTranslator.hpp"



JsonManager JsonManager::c_json_manager;

JsonManager::JsonManager(/* args */){

}

JsonManager::~JsonManager(){

}
//
JsonManager &JsonManager::getInstance(){
    return c_json_manager;
}

UPGRADE_REQ_MSG_TYPE JsonManager::get_upgrade_info(std::string msg){
    UPGRADE_REQ_MSG_TYPE req;
    if(msg.empty()){
        return req;
    }
    json j = json::parse(msg);
    req = j;
    return req;
}

std::string JsonManager::get_response_msg(UPGRADE_REP_MSG_TYPE rep){
    json j = rep;
    return j.dump();
}

std::string JsonManager::get_online_msg(ONLINE_MSG_TYPE online){
    json j = online;
    return j.dump();
}

GET_LOG_REQ JsonManager::get_log_req(std::string msg){
    GET_LOG_REQ req;
    if(msg.empty()){
        return req;
    }
    json j = json::parse(msg);
    req = j;
    return req;
}

REPORT_LOG_REQ_OR_REP JsonManager::report_log_req(std::string msg){
    REPORT_LOG_REQ_OR_REP req;
    if(msg.empty()){
        return req;
    }
    json j = json::parse(msg);
    req = j;
    return req;
}

MSG_HEADER JsonManager::get_msg_head(std::string msg){
    MSG_HEADER head;
    if(msg.empty()){
        return head;
    }
    json j = json::parse(msg);
    head = j;
    return head;
}

std::string JsonManager::get_report_log_msg(REPORT_LOG_REQ_OR_REP data){
  json j = data;
  return j.dump();
}

EXECUTE_CMD_TYPE JsonManager::cmd_execute_req(std::string msg){
    EXECUTE_CMD_TYPE req;
    if(msg.empty()){
        return req;
    }
    json j = json::parse(msg);
    req = j;
    return req;
}

std::string JsonManager::get_cmd_result(EXECUTE_CMD_RESULT data){
  json j = data;
  return j.dump();
}